/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef LIB3D_LIGHT_H
#define LIB3D_LIGHT_H

#include <lib3d/Math_lib3d.h>
#include <Converter.h>
#include <Color.h>

namespace liba
{
namespace lib3d
{

class Light
{
public:
	enum Type { POINT, DIRECTIONAL, AMBIENT, SPOT  };
	static converter::EnumPair<char, Type> TypeNames[];
	Type type;

	Color diffuse;
	Color specular;
	Color ambient;

	Vector position;
	Vector direction;

    double intensity;

	double falloff;// Spot
	double theta;  // Spot
	double phi;    // Spot

	double shadow_priority;

	enum AttenuationType { CONSTANT, LINEAR, QUADRATIC };
	static converter::EnumPair<char, AttenuationType> AttenuationTypeNames[];
	AttenuationType attenuation;

    Light()
        :   type( AMBIENT ),
	        attenuation( CONSTANT ),
			position( 0, 0, 0 ),
			direction( 0, 0, 1 ), 
			intensity( 0 ),
			ambient( 0, 0, 0 ),
			diffuse( 0, 0, 0 ),
			specular( 0, 0, 0 ),
			falloff( 0 ),
			theta( 0 ),
			shadow_priority( 1 ),
			phi( 0 )
	{}
};

} // namespace lib3d

namespace converter
{

template<>
struct ConverterTraits<char, lib3d::Light::Type>
:	public ConverterTraitsEnumBase<char, lib3d::Light::Type, lib3d::Light::TypeNames>
{};

template<>
struct ConverterTraits<char, lib3d::Light::AttenuationType>
:	public ConverterTraitsEnumBase<char, lib3d::Light::AttenuationType, lib3d::Light::AttenuationTypeNames>
{};

} // namespace converter
} // namespace liba
using namespace liba;

#endif //LIB3D_HARD_LIGHT_H